package com.example.pkmedical.Activity.warning;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.example.pkmedical.APP.MyApp;
import com.example.pkmedical.Base.BaseActivity;
import com.example.pkmedical.R;
import com.example.pkmedical.Utils.CommandUtil;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class HeadWarningActivity extends BaseActivity {

    @BindView(R.id.main_house)
    ImageView mainHouse;
    @BindView(R.id.main_house_text)
    TextView mainHouseText;
    @BindView(R.id.warninghead_30_close)
    RelativeLayout warninghead30Close;
    @BindView(R.id.warninghead_45_close)
    RelativeLayout warninghead45Close;
    @BindView(R.id.warninghead_close)
    RelativeLayout warningheadClose;
    @BindView(R.id.warninghead_history)
    Button warningheadHistory;
    @BindView(R.id.warninghead_goback)
    Button warningheadGoback;
    @BindView(R.id.warninghead_30_close_image)
    ImageView warninghead30CloseImage;
    @BindView(R.id.warninghead_30_close_text)
    TextView warninghead30CloseText;
    @BindView(R.id.warninghead_45_close_image)
    ImageView warninghead45CloseImage;
    @BindView(R.id.warninghead_45_close_text)
    TextView warninghead45CloseText;
    @BindView(R.id.warninghead_close_text)
    TextView warningheadCloseText;
    private boolean three = false;
    private boolean four = false;
    private boolean close = false;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_headwarning);
        ButterKnife.bind(this);
    }

    @Override
    public void initData() {

    }

    @Override
    public void initView() {
        mainHouse.setImageResource(R.drawable.img_title_warning);
        mainHouseText.setText(R.string.title_warning);

    }

    @Override
    protected void onResume() {
        super.onResume();
        allOff();
        switch (CommandUtil.HEAD_WARNING_TYPE) {
            case 0:
                closeOn();
                break;
            case 1:
                threeOn();
                break;
            case 2:
                fourOn();
                break;
        }
    }

    @Override
    public void initPresenter() {

    }

    @Override
    public void showDialog(String... msg) {

    }

    @OnClick({R.id.warninghead_30_close, R.id.warninghead_45_close, R.id.warninghead_close, R.id.warninghead_history, R.id.warninghead_goback})
    public void onViewClicked(View view) {

        switch (view.getId()) {
            case R.id.warninghead_30_close:
                allOff();
                threeOn();
                jumpOk();
                break;
            case R.id.warninghead_45_close:
                allOff();
                fourOn();
                jumpOk();
                break;
            case R.id.warninghead_close:
                allOff();
                closeOn();
                break;
            case R.id.warninghead_history:
                break;
            case R.id.warninghead_goback:
                HeadWarningActivity.this.finish();
                break;
        }
    }

    private void threeOn() {
        CommandUtil.HEAD_WARNING_TYPE = 1;
        warninghead30Close.setBackgroundResource(R.drawable.changgui_item_back_on);
        warninghead30CloseImage.setImageResource(R.drawable.img_warning_thirty_on);
        warninghead30CloseText.setTextColor(getResources().getColor(R.color.text_black));
    }

    private void threeOff() {
        warninghead30Close.setBackgroundResource(R.drawable.changgui_item_back_off);
        warninghead30CloseImage.setImageResource(R.drawable.img_warning_thirty_off);
        warninghead30CloseText.setTextColor(getResources().getColor(R.color.white));
    }

    private void fourOn() {
        CommandUtil.HEAD_WARNING_TYPE = 2;
        warninghead45Close.setBackgroundResource(R.drawable.changgui_item_back_on);
        warninghead45CloseImage.setImageResource(R.drawable.img_warning_forty_off);
        warninghead45CloseText.setTextColor(getResources().getColor(R.color.text_black));
    }

    private void fourOff() {
        warninghead45Close.setBackgroundResource(R.drawable.changgui_item_back_off);
        warninghead45CloseImage.setImageResource(R.drawable.img_warning_forty_on);
        warninghead45CloseText.setTextColor(getResources().getColor(R.color.white));
    }

    private void closeOn() {
        CommandUtil.HEAD_WARNING_TYPE = 0;
        warningheadClose.setBackgroundResource(R.drawable.changgui_item_back_on);
        warningheadCloseText.setTextColor(getResources().getColor(R.color.text_black));
    }

    private void closeOff() {
        warningheadClose.setBackgroundResource(R.drawable.changgui_item_back_off);
        warningheadCloseText.setTextColor(getResources().getColor(R.color.white));
    }

    private void allOff() {
        closeOff();
        fourOff();
        threeOff();
    }
    private void jumpOk(){
        Intent intent = new Intent();
        intent.putExtra("warning_type",0);
        intent.setClass(MyApp.getAppContext(),LeaveBedOkActivity.class);
        startActivity(intent);
        HeadWarningActivity.this.finish();
    }
}
